package org.jivesoftware.smackx.provider;

import java.text.ParseException;
import java.util.Date;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.packet.DataForm;
import org.jivesoftware.smackx.packet.StreamInitiation;
import org.jivesoftware.smackx.packet.StreamInitiation.File;
import org.xmlpull.v1.XmlPullParser;

public class StreamInitiationProvider
  implements IQProvider
{
  public IQ parseIQ(XmlPullParser paramXmlPullParser)
    throws Exception
  {
    int i = 0;
    String str1 = paramXmlPullParser.getAttributeValue("", "id");
    String str2 = paramXmlPullParser.getAttributeValue("", "mime-type");
    StreamInitiation localStreamInitiation = new StreamInitiation();
    String str3 = null;
    String str4 = null;
    String str5 = null;
    String str6 = null;
    String str7 = null;
    boolean bool = false;
    DataForm localDataForm = null;
    DataFormProvider localDataFormProvider = new DataFormProvider();
    while (i == 0)
    {
      int j = paramXmlPullParser.next();
      String str8 = paramXmlPullParser.getName();
      String str9 = paramXmlPullParser.getNamespace();
      if (j == 2)
      {
        if (str8.equals("file"))
        {
          str3 = paramXmlPullParser.getAttributeValue("", "name");
          str4 = paramXmlPullParser.getAttributeValue("", "size");
          str5 = paramXmlPullParser.getAttributeValue("", "hash");
          str6 = paramXmlPullParser.getAttributeValue("", "date");
        }
        else if (str8.equals("desc"))
        {
          str7 = paramXmlPullParser.nextText();
        }
        else if (str8.equals("range"))
        {
          bool = true;
        }
        else if ((str8.equals("x")) && (str9.equals("jabber:x:data")))
        {
          localDataForm = (DataForm)localDataFormProvider.parseExtension(paramXmlPullParser);
        }
      }
      else if (j == 3)
        if (str8.equals("si"))
        {
          i = 1;
        }
        else if (str8.equals("file"))
        {
          long l = 0L;
          if ((str4 != null) && (str4.trim().length() != 0))
            try
            {
              l = Long.parseLong(str4);
            }
            catch (NumberFormatException localNumberFormatException)
            {
              localNumberFormatException.printStackTrace();
            }
          Date localDate = new Date();
          if (str6 != null)
            try
            {
              localDate = StringUtils.parseXEP0082Date(str6);
            }
            catch (ParseException localParseException)
            {
            }
          StreamInitiation.File localFile = new StreamInitiation.File(str3, l);
          localFile.setHash(str5);
          localFile.setDate(localDate);
          localFile.setDesc(str7);
          localFile.setRanged(bool);
          localStreamInitiation.setFile(localFile);
        }
    }
    localStreamInitiation.setSesssionID(str1);
    localStreamInitiation.setMimeType(str2);
    localStreamInitiation.setFeatureNegotiationForm(localDataForm);
    return localStreamInitiation;
  }
}

/* Location:           D:\hygieia\userclient\common\libs\easemobchat_2.1.8.jar
 * Qualified Name:     org.jivesoftware.smackx.provider.StreamInitiationProvider
 * JD-Core Version:    0.6.1
 */